
from curl_cffi import requests
import re
import os, pathlib
from selenium import webdriver
from selenium.webdriver.chrome.options import Options

url = 'https://haowallpaper.com'

root = '../static/哲风壁纸'

response = requests.get(url)

if response.status_code == 200:
    list_list = re.findall('<a href="/homeViewLook(.*?)" class="hao-bottom-nav-end col-card" style="cursor:url.*?, auto !important;".*?>', response.text)
    for item in list_list:
        # print(item)

        thumb_url = url+'/homeViewLook'+item
        print(thumb_url)
        headers = {
            'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36',
            'referer':'https://cn.bing.com/',
            'cookie':'askId = ack % 3 A_175793770854220898184874807859;downEdit = true;_ga = GA1.1.1211473489.1757937720;Hm_lvt_3c3619543a455fffe6917f75aba0e02b = 1760532646, 1761735071;HMACCOUNT = 0D6738410FD188BD;isShowElNotice = ok;isWebsiteLog = ok;Hm_lpvt_3c3619543a455fffe6917f75aba0e02b = 1761737429;_ga_XT96CDMYZB = GS2.1.s1761735071$o5$g1$t1761737456$j33$l0$h0'

        }
        thumb_img = requests.get(thumb_url,headers=headers)
        options = Options()
        options.add_argument('--headless')
        driver = webdriver.Chrome(options=options)

        driver.get(thumb_url)
        html = driver.page_source
        driver.quit()
        print(html)
        # photo = re.search('<img src="(.*?)".*?alt=".*?" title="(.*?).*?ins风">',thumb_img.text,re.S)
        # print(photo)

        break
        # if thumb_img.status_code == 200:
        # print(thumb_img.content)
        # with open(f'{root}{item}.jpg','wb') as f:
        #     f.write(thumb_img.content)
        # break



